// pages/subscribe/subscribe.js
var api = require('../../utils/api.js');
Page({

    /**
     * 页面的初始数据
     */
    data: {
      apipath: api.Apipath,
      index: false,
      index0: false,
      index1: false,
      index2: false,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
      var that = this;
      if (wx.getStorageSync('userid')) {
        wx.request({
          url: api.UserRecord,
          data: { userId: wx.getStorageSync('userid') },
          method: 'GET',
          success: function (res) {
            if(res.data.code==200){
              that.setData({
                recordList: res.data.data,//专家姓名
                index:false
              })
            }
            
          },
        })
        wx.request({
          url: api.UserRecord,
          data: { userId: wx.getStorageSync('userid'), status: 0 },
          method: 'GET',
          success: function (res) {
            if (res.data.code == 200) {
              that.setData({
                recordList0: res.data.data,//专家姓名
                index0: false
              })
            }

          },
        })
        wx.request({
          url: api.UserRecord,
          data: { userId: wx.getStorageSync('userid'), status: 1 },
          method: 'GET',
          success: function (res) {
            if (res.data.code == 200) {
              that.setData({
                recordList1: res.data.data,//专家姓名
                index1: false
              })
            }else{
              that.setData({
                index1: true
              })
            }
          },
        })
        wx.request({
          url: api.UserRecord,
          data: { userId: wx.getStorageSync('userid'), status: 2 },
          method: 'GET',
          success: function (res) {
            if (res.data.code == 200) {
              that.setData({
                recordList2: res.data.data,//专家姓名
                index2: false
              })
            } else {
              that.setData({
                index2: true
              })
            }
          },
        })
      } else {
        wx.navigateTo({
          url: '/pages/signin/signin',
        })
      }
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})